$(function() {
	initPager();
});		

function initPager(){
	$("#Pagination").pagination(totalResult, {
		callback: function(new_page_index, pagination_container){
			var oldLocation = location.href;
			var pa = "currentPage=" + (new_page_index+1);
			var shoC = "showCount=" + showCount;
			var index = oldLocation.lastIndexOf("?");
			if (index == -1){
				location.href = oldLocation + "?" + pa + "&" + shoC;
			}else if (oldLocation.indexOf("currentPage") == -1){
				location.href = oldLocation + "&" + pa;
			}else if (oldLocation.indexOf("showCount") == -1){
				location.href = oldLocation + "&" + shoC;
			}else{
				var temp = oldLocation.replace(/currentPage=\d+/, pa);
				var newLocation = temp.replace(/showCount=\d+/, shoC);
				location.href = newLocation;
			}
			return false;
		},
		items_per_page:showCount, 
		load_first_page:false,
		prev_text:'上一页',
		next_text:'下一页',
		ellipse_text:'...',
		num_edge_entries:1,
		num_display_entries:5,
		current_page:currentPage,
	});
}

// 重置
function the_reset(){
	$("#search-form input[type='text']").val('');
}